<cfcomponent>

	<cffunction name="init" output="false" access="public" returntype="saveCategory" hint="I perform initialization for this component">
		<cfargument name="CategoryDAO" type="any" required="true" hint="I am the Kalendar Category Data abstraction"/>
		<cfargument name="Validator" type="any" required="true" hint="I perform validation functions for this component">
	
			<cfset variables.instance.CategoryDAO = arguments.CategoryDAO />
			<cfset variables.instance.Validator = arguments.Validator />
		
		<cfreturn this />	
	</cffunction>
	
	<cffunction name="execute" output="false" access="public" returntype="boolean" hint="I execute this command">
		<cfargument name="Category" type="any" required="true"/>
		<cfargument name="UserMsg" type="any" required="true" >
		<cfset var returnState = false />
		
		<!--- <cftransaction action="begin"> --->
		<!--- validate the passed arguments --->
		<cfif getValidator().validate( argumentcollection=arguments ) >

			<cfif getCategoryDAO().save( arguments.Category )>
				<cfset arguments.UserMsg.addSuccess("Category Saved!") />
			<cfelse>
				<!--- Ok, that didn't work. Make a note of it and just get out of this function. --->
				<cfset arguments.UserMsg.addError("Category Save Failed!") />
				<cfreturn false />
			</cfif>

		<cfelse>
			<cfreturn false />
		</cfif>

		<!--- </cftransaction> --->
		
		<cfset returnState = true >

		<cfreturn returnState />
		
	</cffunction>
	
	<cffunction name="getCategoryDAO" access="private" output="false" returntype="any">
		<cfreturn variables.instance.CategoryDAO />
	</cffunction>
	
	<!--- This for the composed validator --->
	<cffunction name="getValidator" access="private" output="false" returntype="any">
		<cfreturn variables.instance.Validator />
	</cffunction>
	
</cfcomponent>